import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
import store from './store/index'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import './utils/permission'
import '../public/public.css'
import zhCn from "element-plus/es/locale/lang/zh-cn";
// import { defineCustomElements, imkit } from '@rongcloud/imkit' // imkit 为核心模块
// defineCustomElements() // im
import { showAiNotifications, fetchAiReminders } from './utils/aiNotifications'
import AiChatWindow from './views/AiChatWindow.vue'

const app = createApp(App)
app.component('AiChatWindow', AiChatWindow)


app.config.globalProperties.$showAiNotifications = showAiNotifications
app.config.globalProperties.$fetchAiReminders = fetchAiReminders
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(ElementPlus, { locale: zhCn}).use(router).use(store).use(useRouter)
app.mount('#app')
router.isReady().then(() => {
    if (localStorage.getItem('pass')) {
            fetchAiReminders().then(msgs => {
                  if (msgs.length > 0) showAiNotifications(msgs)
                })
          }
    })
